package cn.giantsoft.simpleweather.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by qiaox on 2017/10/20.
 */

public class SimpleSQLiteOpenHelper extends SQLiteOpenHelper {
    /**
     * 省建表语句
     */
    private static final String CREATE_PROVINCE = "create table Province" +
            "(id integer primary key autoincrement," +
            "province_name text," +
            "province_code text)";
    /**
     * 市建表语句
     */
    private static final String CREATE_CITY = "create table City" +
            "(id integer primary key autoincrement," +
            "city_name text," +
            "city_code text," +
            "province_id integer)";
    /**
     * 县建表语句
     */
    private static final String CREATE_COUNTY = "create table County" +
            "(id integer primary key autoincrement," +
            "county_name text," +
            "county_code text," +
            "city_id integer)";

    public SimpleSQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_PROVINCE);
        db.execSQL(CREATE_CITY);
        db.execSQL(CREATE_COUNTY);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
